Calendar All Tests
Current file: /home/estudydev/workspace/eStudy_svn/web/teams/classes/class.team.inc.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 22
0.00 %0.00%
0.00% 0 / 210
 
Team
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 22
0.00 %0.00%
0.00% 0 / 210
 public function Team($teamID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 21
 public function setData($data)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 17
 private function validateData($data)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 14
 public function createTeam()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 7
 public function deleteTeam()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 9
 public function setDefaultValues()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 7
 public function getFormRow($data = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 23
 public function getID()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getName()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function validateName($name)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 8
 public function setName($name)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 14
 public function getStyle()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function validateStyle($name)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 11
 public function setStyle($name)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 18
 public function getLogo()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function validateLogo($url)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 4
 public function setLogo($name)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 18
 public function getMaxMembers()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function validateMaxMembers($maxMembers)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 3
 public function setMaxMembers($maxMembers)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 15
 public function getCourseID()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function setCourseID($courseID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 15


       1                 : <?php                                                                                                                                                                                                                                                                                                                                                                                                                                               
       2                 : /*--------------------------------------------------------------------------+                                                                                                                                                                                                                                                                                                                                                                       
       3                 :  This file is part of eStudy.                                                                                                                                                                                                                                                                                                                                                                                                                       
       4                 :  teams/classes/class.team.inc.php                                                                                                                                                                                                                                                                                                                                                                                                                   
       5                 :  - Modulgruppe:  Teams                                                                                                                                                                                                                                                                                                                                                                                                                              
       6                 :  - Beschreibung: Klasse zum Erstellen eines Team-Objekts                                                                                                                                                                                                                                                                                                                                                                                            
       7                 :  und Bereitstellen von zugehörigen Funktionen.                                                                                                                                                                                                                                                                                                                                                                                                     
       8                 :  - Version:      0.2, 05/11/06                                                                                                                                                                                                                                                                                                                                                                                                                      
       9                 :  - Autor(en):    Clemens Weiß <clemens.weiss@mni.fh-giessen.de>                                                                                                                                                                                                                                                                                                                                                                                    
      10                 :  +---------------------------------------------------------------------------+                                                                                                                                                                                                                                                                                                                                                                      
      11                 :  This program is free software; you can redistribute it and/or                                                                                                                                                                                                                                                                                                                                                                                      
      12                 :  modify it under the terms of the GNU General Public License                                                                                                                                                                                                                                                                                                                                                                                        
      13                 :  as published by the Free Software Foundation; either version 2                                                                                                                                                                                                                                                                                                                                                                                     
      14                 :  of the License, or any later version.                                                                                                                                                                                                                                                                                                                                                                                                              
      15                 :  +---------------------------------------------------------------------------+                                                                                                                                                                                                                                                                                                                                                                      
      16                 :  This program is distributed in the hope that it will be useful,                                                                                                                                                                                                                                                                                                                                                                                    
      17                 :  but WITHOUT ANY WARRANTY; without even the implied warranty of                                                                                                                                                                                                                                                                                                                                                                                     
      18                 :  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                                                                                                                                                                                                                                                                                                                                                                      
      19                 :  GNU General Public License for more details.                                                                                                                                                                                                                                                                                                                                                                                                       
      20                 :  You should have received a copy of the GNU General Public License                                                                                                                                                                                                                                                                                                                                                                                  
      21                 :  along with this program; if not, write to the Free Software                                                                                                                                                                                                                                                                                                                                                                                        
      22                 :  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                                                                                                                                                                                                                                                                                                                                                                        
      23                 :  +--------------------------------------------------------------------------*/                                                                                                                                                                                                                                                                                                                                                                      
      24                 : /**                                                                                                                                                                                                                                                                                                                                                                                                                                                 
      25                 :  * Klasse zum Erstellen eines Team-Objekts                                                                                                                                                                                                                                                                                                                                                                                                          
      26                 :  * und Bereitstellen von zugehörigen Funktionen.                                                                                                                                                                                                                                                                                                                                                                                                   
      27                 :  * @package eStudy.Teams                                                                                                                                                                                                                                                                                                                                                                                                                            
      28                 :  * @version 0.2, 05/11/06                                                                                                                                                                                                                                                                                                                                                                                                                           
      29                 :  * @author  Clemens Weiß <clemens.weiss@mni.fh-giessen.de>                                                                                                                                                                                                                                                                                                                                                                                         
      30                 :  */                                                                                                                                                                                                                                                                                                                                                                                                                                                 
      31                 : if(! defined("PATH_TO_ROOT")) define("PATH_TO_ROOT","../../");                                                                                                                                                                                                                                                                                                                                                                                      
      32                 : require_once (PATH_TO_ROOT."style/classes/class.style.inc.php");                                                                                                                                                                                                                                                                                                                                                                                    
      33                 : require_once (PATH_TO_ROOT."common/classes/class.data.inc.php");                                                                                                                                                                                                                                                                                                                                                                                    
      34                 : require_once (PATH_TO_ROOT."common/classes/class.output.inc.php");                                                                                                                                                                                                                                                                                                                                                                                  
      35                 : require_once (PATH_TO_ROOT."common/classes/class.utilities.inc.php");                                                                                                                                                                                                                                                                                                                                                                               
      36                 :                                                                                                                                                                                                                                                                                                                                                                                                                                                     
      37                 : class Team {                                                                                                                                                                                                                                                                                                                                                                                                                                        
      38                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
      39                 :      * ID des Teams                                                                                                                                                                                                                                                                                                                                                                                                                                 
      40                 :      * @var integer                                                                                                                                                                                                                                                                                                                                                                                                                                 
      41                 :      * @access private                                                                                                                                                                                                                                                                                                                                                                                                                              
      42                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
      43                 :     private $ID;                                                                                                                                                                                                                                                                                                                                                                                                                                    
      44                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
      45                 :      * Name des Teams                                                                                                                                                                                                                                                                                                                                                                                                                               
      46                 :      * @var string                                                                                                                                                                                                                                                                                                                                                                                                                                  
      47                 :      * @access private                                                                                                                                                                                                                                                                                                                                                                                                                              
      48                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
      49                 :     private $name;                                                                                                                                                                                                                                                                                                                                                                                                                                  
      50                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
      51                 :      * Kurs-ID des Teams                                                                                                                                                                                                                                                                                                                                                                                                                            
      52                 :      * @var integer                                                                                                                                                                                                                                                                                                                                                                                                                                 
      53                 :      * @access private                                                                                                                                                                                                                                                                                                                                                                                                                              
      54                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
      55                 :     private $courseID;                                                                                                                                                                                                                                                                                                                                                                                                                              
      56                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
      57                 :      * Maximale Teilnehmerzahl des Teams                                                                                                                                                                                                                                                                                                                                                                                                            
      58                 :      * @var integer                                                                                                                                                                                                                                                                                                                                                                                                                                 
      59                 :      * @access private                                                                                                                                                                                                                                                                                                                                                                                                                              
      60                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
      61                 :     private $maxMembers;                                                                                                                                                                                                                                                                                                                                                                                                                            
      62                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
      63                 :      * Team-Style                                                                                                                                                                                                                                                                                                                                                                                                                                   
      64                 :      * @var string                                                                                                                                                                                                                                                                                                                                                                                                                                  
      65                 :      * @access private                                                                                                                                                                                                                                                                                                                                                                                                                              
      66                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
      67                 :     private $style;                                                                                                                                                                                                                                                                                                                                                                                                                                 
      68                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
      69                 :      * Team-Logo                                                                                                                                                                                                                                                                                                                                                                                                                                    
      70                 :      * @var string                                                                                                                                                                                                                                                                                                                                                                                                                                  
      71                 :      * @access private                                                                                                                                                                                                                                                                                                                                                                                                                              
      72                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
      73                 :     private $logo;                                                                                                                                                                                                                                                                                                                                                                                                                                  
      74                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
      75                 :      * Fehlerstrings                                                                                                                                                                                                                                                                                                                                                                                                                                
      76                 :      * @var string                                                                                                                                                                                                                                                                                                                                                                                                                                  
      77                 :      * @access private                                                                                                                                                                                                                                                                                                                                                                                                                              
      78                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
      79                 :     private $errors;                                                                                                                                                                                                                                                                                                                                                                                                                                
      80                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
      81                 :      * Konstruktor.                                                                                                                                                                                                                                                                                                                                                                                                                                 
      82                 :      * Erstellt das Team-Objekt mit den Daten des per ID bestimmten Teams.                                                                                                                                                                                                                                                                                                                                                                          
      83                 :      * Wird eine ungültige ID (oder 0) übergeben, wird ein neues Team                                                                                                                                                                                                                                                                                                                                                                             
      84                 :      * erstellt.                                                                                                                                                                                                                                                                                                                                                                                                                                    
      85                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
      86                 :      * @access public                                                                                                                                                                                                                                                                                                                                                                                                                               
      87                 :      * @param int $teamID ID des Teams oder 0 für neues Team                                                                                                                                                                                                                                                                                                                                                                                       
      88                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
      89                 :     public function Team($teamID) {                                                                                                                                                                                                                                                                                                                                                                                                                 
      90               0 :         global $db, $settings;                                                                                                                                                                                                                                                                                                                                                                                                                      
      91               0 :         $dbp = $settings["dbPrefix"];                                                                                                                                                                                                                                                                                                                                                                                                               
      92               0 :         $this->errors = "";                                                                                                                                                                                                                                                                                                                                                                                                                         
      93               0 :         $newTeam = false;                                                                                                                                                                                                                                                                                                                                                                                                                           
      94               0 :         if (strval(intval($teamID)) == $teamID && $teamID > 0) {                                                                                                                                                                                                                                                                                                                                                                                    
      95               0 :             $teamData = $db->get_row("SELECT * FROM {$dbp}teams WHERE id='$teamID'");                                                                                                                                                                                                                                                                                                                                                               
      96               0 :             if ($db->num_rows) {                                                                                                                                                                                                                                                                                                                                                                                                                    
      97               0 :                 $this->ID = (int)$teamData->id;                                                                                                                                                                                                                                                                                                                                                                                                     
      98               0 :                 $this->name = $teamData->name;                                                                                                                                                                                                                                                                                                                                                                                                      
      99               0 :                 $this->courseID = (int)$teamData->course_id;                                                                                                                                                                                                                                                                                                                                                                                        
     100               0 :                 $this->maxMembers = (int)$teamData->max_members;                                                                                                                                                                                                                                                                                                                                                                                    
     101               0 :                 $this->style = $teamData->style;                                                                                                                                                                                                                                                                                                                                                                                                    
     102               0 :                 $this->logo = $teamData->logo;                                                                                                                                                                                                                                                                                                                                                                                                      
     103               0 :             } else {                                                                                                                                                                                                                                                                                                                                                                                                                                
     104               0 :                 $newTeam = true;                                                                                                                                                                                                                                                                                                                                                                                                                    
     105                 :             }                                                                                                                                                                                                                                                                                                                                                                                                                                       
     106               0 :         } else {                                                                                                                                                                                                                                                                                                                                                                                                                                    
     107               0 :             $newTeam = true;                                                                                                                                                                                                                                                                                                                                                                                                                        
     108                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     109               0 :         if ($newTeam) {                                                                                                                                                                                                                                                                                                                                                                                                                             
     110               0 :             $this->setDefaultValues();                                                                                                                                                                                                                                                                                                                                                                                                              
     111               0 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     112               0 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     113                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
     114                 :      * Versucht, die im übergebenen Array vorhandenen Daten anhand der                                                                                                                                                                                                                                                                                                                                                                             
     115                 :      * assoziativen Array-Indizes als neue Team-Daten abzuspeichern. Dabei                                                                                                                                                                                                                                                                                                                                                                          
     116                 :      * kann es sich zum Beispiel um das $_POST-Array handeln. Es werden dabei                                                                                                                                                                                                                                                                                                                                                                       
     117                 :      * entweder alle oder keine Daten gespeichert. Sind einige der Daten                                                                                                                                                                                                                                                                                                                                                                            
     118                 :      * fehlerhaft, wird ein String mit Fehlermeldungen in $this->errors gespeichert                                                                                                                                                                                                                                                                                                                                                                 
     119                 :      * und false zurückgegeben, sonst true.                                                                                                                                                                                                                                                                                                                                                                                                        
     120                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
     121                 :      * @access public                                                                                                                                                                                                                                                                                                                                                                                                                               
     122                 :      * @param array $data Assoziatives Array mit den neuen Werten                                                                                                                                                                                                                                                                                                                                                                                   
     123                 :      * @return boolean Erfolgswert                                                                                                                                                                                                                                                                                                                                                                                                                  
     124                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
     125                 :     public function setData($data) {                                                                                                                                                                                                                                                                                                                                                                                                                
     126               0 :         $this->errors = $this->validateData($data);                                                                                                                                                                                                                                                                                                                                                                                                 
     127               0 :         if (empty($this->errors)) {                                                                                                                                                                                                                                                                                                                                                                                                                 
     128               0 :             if (!$this->setName($data["name"])) {                                                                                                                                                                                                                                                                                                                                                                                                   
     129               0 :                 $this->errors.= "Name konnte nicht gespeichert werden.\n";                                                                                                                                                                                                                                                                                                                                                                          
     130               0 :                 return false;                                                                                                                                                                                                                                                                                                                                                                                                                       
     131                 :             }                                                                                                                                                                                                                                                                                                                                                                                                                                       
     132               0 :             if (!$this->setMaxMembers($data["maxMembers"])) {                                                                                                                                                                                                                                                                                                                                                                                       
     133               0 :                 $this->errors.= "Maximale Teilnehmerzahl konnte nicht gespeichert werden.";                                                                                                                                                                                                                                                                                                                                                         
     134               0 :                 return false;                                                                                                                                                                                                                                                                                                                                                                                                                       
     135                 :             }                                                                                                                                                                                                                                                                                                                                                                                                                                       
     136               0 :             if (!$this->setStyle($data["style"])) {                                                                                                                                                                                                                                                                                                                                                                                                 
     137               0 :                 $this->errors.= "Style konnte nicht gespeichert werden.";                                                                                                                                                                                                                                                                                                                                                                           
     138               0 :                 return false;                                                                                                                                                                                                                                                                                                                                                                                                                       
     139                 :             }                                                                                                                                                                                                                                                                                                                                                                                                                                       
     140               0 :             if (!$this->setLogo($data["logo"])) {                                                                                                                                                                                                                                                                                                                                                                                                   
     141               0 :                 $this->errors.= "Logo konnte nicht gespeichert werden.";                                                                                                                                                                                                                                                                                                                                                                            
     142               0 :                 return false;                                                                                                                                                                                                                                                                                                                                                                                                                       
     143                 :             }                                                                                                                                                                                                                                                                                                                                                                                                                                       
     144               0 :             return true;                                                                                                                                                                                                                                                                                                                                                                                                                            
     145                 :         } else {                                                                                                                                                                                                                                                                                                                                                                                                                                    
     146               0 :             echo $this->errors;                                                                                                                                                                                                                                                                                                                                                                                                                     
     147                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     148               0 :         return false;                                                                                                                                                                                                                                                                                                                                                                                                                               
     149                 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     150                 :                                                                                                                                                                                                                                                                                                                                                                                                                                                     
     151                 :     private function validateData($data) {                                                                                                                                                                                                                                                                                                                                                                                                          
     152               0 :                 $errors = "";                                                                                                                                                                                                                                                                                                                                                                                                                       
     153               0 :                 if (($result = $this->validateName($data["name"])) !== true) {                                                                                                                                                                                                                                                                                                                                                                      
     154               0 :                         $errors.= $result."\n";                                                                                                                                                                                                                                                                                                                                                                                                     
     155               0 :                 }                                                                                                                                                                                                                                                                                                                                                                                                                                   
     156               0 :                 if (($result = $this->validateMaxMembers($data["maxMembers"])) !== true) {                                                                                                                                                                                                                                                                                                                                                          
     157               0 :                         $errors.= $result."\n";                                                                                                                                                                                                                                                                                                                                                                                                     
     158               0 :                 }                                                                                                                                                                                                                                                                                                                                                                                                                                   
     159               0 :                 if (($result = $this->validateStyle($data["style"])) !== true) {                                                                                                                                                                                                                                                                                                                                                                    
     160               0 :                         $errors.= $result."\n";                                                                                                                                                                                                                                                                                                                                                                                                     
     161               0 :                 }                                                                                                                                                                                                                                                                                                                                                                                                                                   
     162               0 :                 if (($result = $this->validateLogo($data["logo"])) !== true) {                                                                                                                                                                                                                                                                                                                                                                      
     163               0 :                         $errors.= $result."\n";                                                                                                                                                                                                                                                                                                                                                                                                     
     164               0 :                 }                                                                                                                                                                                                                                                                                                                                                                                                                                   
     165               0 :         return $errors;                                                                                                                                                                                                                                                                                                                                                                                                                             
     166                 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     167                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
     168                 :      * Erstellt den grundlegenden Datenbankeintrag für das Team. Gesetzt wird                                                                                                                                                                                                                                                                                                                                                                      
     169                 :      * nur die Kurs-ID, die anderen Felder werden mit ihren Standardwerten belegt.                                                                                                                                                                                                                                                                                                                                                                  
     170                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
     171                 :      * @access private                                                                                                                                                                                                                                                                                                                                                                                                                              
     172                 :      * @return boolean Erfolgswert                                                                                                                                                                                                                                                                                                                                                                                                                  
     173                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
     174                 :     function createTeam() {                                                                                                                                                                                                                                                                                                                                                                                                                         
     175               0 :         global $db, $settings;                                                                                                                                                                                                                                                                                                                                                                                                                      
     176               0 :         $dbp = $settings["dbPrefix"];                                                                                                                                                                                                                                                                                                                                                                                                               
     177               0 :         $db->query("INSERT INTO {$dbp}teams (course_id) VALUES ('$this->courseID')");                                                                                                                                                                                                                                                                                                                                                               
     178               0 :         if ($db->rows_affected) {                                                                                                                                                                                                                                                                                                                                                                                                                   
     179               0 :             $this->ID = $db->insert_id;                                                                                                                                                                                                                                                                                                                                                                                                             
     180               0 :             return true;                                                                                                                                                                                                                                                                                                                                                                                                                            
     181                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     182               0 :         return false;                                                                                                                                                                                                                                                                                                                                                                                                                               
     183                 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     184                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
     185                 :      * Löscht dieses Team und alle Zuordnungen zu Mitgliedern. Alle                                                                                                                                                                                                                                                                                                                                                                                
     186                 :      * Eigenschaften dieses Objekts werden auf Standardwerte gesetzt, so dass                                                                                                                                                                                                                                                                                                                                                                       
     187                 :      * damit gleich ein neues Team erzeugt werden kann.                                                                                                                                                                                                                                                                                                                                                                                             
     188                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
     189                 :      * @access public                                                                                                                                                                                                                                                                                                                                                                                                                               
     190                 :      * @return boolean Erfolgswert                                                                                                                                                                                                                                                                                                                                                                                                                  
     191                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
     192                 :     function deleteTeam() {                                                                                                                                                                                                                                                                                                                                                                                                                         
     193               0 :         global $db, $settings;                                                                                                                                                                                                                                                                                                                                                                                                                      
     194               0 :         $dbp = $settings["dbPrefix"];                                                                                                                                                                                                                                                                                                                                                                                                               
     195               0 :         $db->query("DELETE FROM {$dbp}teams WHERE id='$this->ID'");                                                                                                                                                                                                                                                                                                                                                                                 
     196               0 :         if (!$db->rows_affected) {                                                                                                                                                                                                                                                                                                                                                                                                                  
     197               0 :             return false;                                                                                                                                                                                                                                                                                                                                                                                                                           
     198                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     199               0 :         $db->query("DELETE FROM {$dbp}user_team WHERE team_id='$this->ID'");                                                                                                                                                                                                                                                                                                                                                                        
     200               0 :         $db->query("DELETE FROM {$dbp}team_artefacts WHERE team_id='$this->ID'");                                                                                                                                                                                                                                                                                                                                                                   
     201               0 :         $this->setDefaultValues();                                                                                                                                                                                                                                                                                                                                                                                                                  
     202               0 :         return true;                                                                                                                                                                                                                                                                                                                                                                                                                                
     203                 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     204                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
     205                 :      * Setzt Standardwerte für dieses Objekt, speichert die Änderungen aber                                                                                                                                                                                                                                                                                                                                                                       
     206                 :      * nicht in der Datenbank.                                                                                                                                                                                                                                                                                                                                                                                                                      
     207                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
     208                 :      * @access private                                                                                                                                                                                                                                                                                                                                                                                                                              
     209                 :      * @return void                                                                                                                                                                                                                                                                                                                                                                                                                                 
     210                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
     211                 :     function setDefaultValues() {                                                                                                                                                                                                                                                                                                                                                                                                                   
     212               0 :         $this->ID = 0;                                                                                                                                                                                                                                                                                                                                                                                                                              
     213               0 :         $this->name = "";                                                                                                                                                                                                                                                                                                                                                                                                                           
     214               0 :         $this->courseID = $_SESSION["course"];                                                                                                                                                                                                                                                                                                                                                                                                      
     215               0 :         $this->maxMembers = 0;                                                                                                                                                                                                                                                                                                                                                                                                                      
     216               0 :         $this->style = "";                                                                                                                                                                                                                                                                                                                                                                                                                          
     217               0 :         $this->logo = "";                                                                                                                                                                                                                                                                                                                                                                                                                           
     218               0 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     219                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
     220                 :      * Gibt eine Tabellenzeile zurück, die die Formularelemente zum Bearbeiten der                                                                                                                                                                                                                                                                                                                                                                 
     221                 :      * Team-Eigenschaften enthält und eventuelle Fehlermeldungen.                                                                                                                                                                                                                                                                                                                                                                                  
     222                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
     223                 :      * @access public                                                                                                                                                                                                                                                                                                                                                                                                                               
     224                 :      * @param array $data Assoziatives Array der im Formular anzuzeigenden Daten                                                                                                                                                                                                                                                                                                                                                                    
     225                 :      * @return Formular                                                                                                                                                                                                                                                                                                                                                                                                                             
     226                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
     227                 :     function getFormRow($data = null) {                                                                                                                                                                                                                                                                                                                                                                                                             
     228               0 :         if (isset($data["name"])) $name = Data::gpcUnescape($data["name"]);                                                                                                                                                                                                                                                                                                                                                                         
     229               0 :         else $name = $this->name;                                                                                                                                                                                                                                                                                                                                                                                                                   
     230               0 :         if (isset($data["maxMembers"])) $maxMembers = Data::gpcUnescape($data["maxMembers"]);                                                                                                                                                                                                                                                                                                                                                       
     231               0 :         else $maxMembers = $this->maxMembers;                                                                                                                                                                                                                                                                                                                                                                                                       
     232               0 :         if (isset($data["style"])) $teamStyle = Data::gpcUnescape($data["style"]);                                                                                                                                                                                                                                                                                                                                                                  
     233               0 :         else $teamStyle = $this->style;                                                                                                                                                                                                                                                                                                                                                                                                             
     234               0 :         if (isset($data["logo"])) $logo = Data::gpcUnescape($data["logo"]);                                                                                                                                                                                                                                                                                                                                                                         
     235               0 :         else $logo = $this->logo;                                                                                                                                                                                                                                                                                                                                                                                                                   
     236               0 :         $output = "<tr";                                                                                                                                                                                                                                                                                                                                                                                                                            
     237               0 :         if (!empty($this->errors)) {                                                                                                                                                                                                                                                                                                                                                                                                                
     238               0 :             $output .= " class='error'>"."<td colspan='5'>".nl2br(Data::toHTML($this->errors, false)) ."</td>"."</tr><tr class='error'";                                                                                                                                                                                                                                                                                                            
     239               0 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     240               0 :         $output .=  "><td style='text-align: center;'>".($this->ID == 0 ? "<strong>Neu:</strong>" : "<input type='checkbox' value='".$this->ID."' name='teams[]' />") ."</td>"."<td><input type='text' name='name".$this->ID."' value=\"".Data::toHTML($name, false) ."\" maxlength='100' size='24' /></td>"."<td><input type='text' name='maxMembers".$this->ID."' value=\"".Data::toHTML($maxMembers, false) ."\" maxlength='4' size='5' /></td>";
     241               0 :         $styles = Style::getStyleTemplates();                                                                                                                                                                                                                                                                                                                                                                                                       
     242               0 :         $output .=  "<td><select name='style".$this->ID."'>";                                                                                                                                                                                                                                                                                                                                                                                       
     243               0 :         $output .=  "<option value='' style='font-style: italic;'>Benutzer-Style</option>";                                                                                                                                                                                                                                                                                                                                                         
     244               0 :         foreach($styles as $style) {                                                                                                                                                                                                                                                                                                                                                                                                                
     245               0 :             $output .=  "<option value=\"$style[0]\"".($style[0] == $teamStyle ? " selected='selected'" : "") .">".Data::toHTML($style[1], false) ."</option>";                                                                                                                                                                                                                                                                                     
     246               0 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     247               0 :         $output .=  "</select></td>";                                                                                                                                                                                                                                                                                                                                                                                                               
     248               0 :         $output .=  "<td><input type='text' name='logo".$this->ID."' value=\"".Data::toHTML($logo, false) ."\" maxlength='100' size='24' /></td>";                                                                                                                                                                                                                                                                                                  
     249               0 :         $output .=  "</tr>\n";                                                                                                                                                                                                                                                                                                                                                                                                                      
     250               0 :         return $output;                                                                                                                                                                                                                                                                                                                                                                                                                             
     251                 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     252                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
     253                 :      * Gibt die ID des Teams zurück.                                                                                                                                                                                                                                                                                                                                                                                                               
     254                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
     255                 :      * @access public                                                                                                                                                                                                                                                                                                                                                                                                                               
     256                 :      * @return int ID des Teams                                                                                                                                                                                                                                                                                                                                                                                                                     
     257                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
     258                 :     function getID() {                                                                                                                                                                                                                                                                                                                                                                                                                              
     259               0 :         return $this->ID;                                                                                                                                                                                                                                                                                                                                                                                                                           
     260                 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     261                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
     262                 :      * Gibt den Namen des Teams zurück.                                                                                                                                                                                                                                                                                                                                                                                                            
     263                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
     264                 :      * @access public                                                                                                                                                                                                                                                                                                                                                                                                                               
     265                 :      * @return string Name des Teams                                                                                                                                                                                                                                                                                                                                                                                                                
     266                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
     267                 :     function getName() {                                                                                                                                                                                                                                                                                                                                                                                                                            
     268               0 :         return $this->name;                                                                                                                                                                                                                                                                                                                                                                                                                         
     269                 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     270                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
     271                 :      * Überprüft den übergebenen Namen auf Gültigkeit.                                                                                                                                                                                                                                                                                                                                                                                          
     272                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
     273                 :      * @access public                                                                                                                                                                                                                                                                                                                                                                                                                               
     274                 :      * @param string $name Der zu überprüfende String                                                                                                                                                                                                                                                                                                                                                                                             
     275                 :      * @return mixed String mit Fehlerangabe oder true bei Erfolg                                                                                                                                                                                                                                                                                                                                                                                   
     276                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
     277                 :     function validateName($name) {                                                                                                                                                                                                                                                                                                                                                                                                                  
     278               0 :         global $db, $settings;                                                                                                                                                                                                                                                                                                                                                                                                                      
     279               0 :         $dbp = $settings["dbPrefix"];                                                                                                                                                                                                                                                                                                                                                                                                               
     280               0 :         $name = trim(Data::gpcUnescape($name));                                                                                                                                                                                                                                                                                                                                                                                                     
     281               0 :         if (empty($name)) return "Der Name wurde nicht angegeben.";                                                                                                                                                                                                                                                                                                                                                                                 
     282               0 :         if (!preg_match("/^[a-zäöüßÄÖÜ0-9\/\-_ \(\)&'\"\.,]+$/i", $name)) return "Der Name enthält ungültige Zeichen.";                                                                                                                                                                                                                                                                                                                    
     283               0 :         if (strlen($name) > 100) return "Der Name ist zu lang.";                                                                                                                                                                                                                                                                                                                                                                                    
     284               0 :         if ($this->ID == 0 && $db->get_var("SELECT COUNT(*) FROM {$dbp}teams WHERE name='".Data::toMysql($name, false) ."' AND course_id='$this->courseID'") > 0) return "Ein Team mit diesem Namen ist bereits vorhanden.";                                                                                                                                                                                                                        
     285               0 :         return true;                                                                                                                                                                                                                                                                                                                                                                                                                                
     286                 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     287                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
     288                 :      * Speichert den übergebenen String als neuen Namen dieses Teams.                                                                                                                                                                                                                                                                                                                                                                              
     289                 :      * Der String sollte vorher mit der Methode validateName() validiert worden                                                                                                                                                                                                                                                                                                                                                                     
     290                 :      * sein!                                                                                                                                                                                                                                                                                                                                                                                                                                        
     291                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
     292                 :      * @access public                                                                                                                                                                                                                                                                                                                                                                                                                               
     293                 :      * @param string $name Zu speichernder Name                                                                                                                                                                                                                                                                                                                                                                                                     
     294                 :      * @return boolean Erfolgswert                                                                                                                                                                                                                                                                                                                                                                                                                  
     295                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
     296                 :     function setName($name) {                                                                                                                                                                                                                                                                                                                                                                                                                       
     297               0 :         global $db, $settings;                                                                                                                                                                                                                                                                                                                                                                                                                      
     298               0 :         $dbp = $settings["dbPrefix"];                                                                                                                                                                                                                                                                                                                                                                                                               
     299               0 :         $name = trim($name);                                                                                                                                                                                                                                                                                                                                                                                                                        
     300               0 :         if ($this->name == Data::gpcUnescape($name)) {                                                                                                                                                                                                                                                                                                                                                                                              
     301               0 :             return true;                                                                                                                                                                                                                                                                                                                                                                                                                            
     302                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     303               0 :         if ($this->ID == 0) {                                                                                                                                                                                                                                                                                                                                                                                                                       
     304               0 :             if (!$this->createTeam()) {                                                                                                                                                                                                                                                                                                                                                                                                             
     305               0 :                 return false;                                                                                                                                                                                                                                                                                                                                                                                                                       
     306                 :             }                                                                                                                                                                                                                                                                                                                                                                                                                                       
     307               0 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     308               0 :         $db->query("UPDATE {$dbp}teams SET name='".Data::toMysql($name) ."' WHERE id='$this->ID'");                                                                                                                                                                                                                                                                                                                                                 
     309               0 :         if ($db->rows_affected) {                                                                                                                                                                                                                                                                                                                                                                                                                   
     310               0 :             $this->name = Data::gpcUnescape($name);                                                                                                                                                                                                                                                                                                                                                                                                 
     311               0 :             return true;                                                                                                                                                                                                                                                                                                                                                                                                                            
     312                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     313               0 :         return false;                                                                                                                                                                                                                                                                                                                                                                                                                               
     314                 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     315                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
     316                 :      * Gibt den Style des Teams zurück.                                                                                                                                                                                                                                                                                                                                                                                                            
     317                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
     318                 :      * @access public                                                                                                                                                                                                                                                                                                                                                                                                                               
     319                 :      * @return string Style des Teams                                                                                                                                                                                                                                                                                                                                                                                                               
     320                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
     321                 :     function getStyle() {                                                                                                                                                                                                                                                                                                                                                                                                                           
     322               0 :         return $this->style;                                                                                                                                                                                                                                                                                                                                                                                                                        
     323                 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     324                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
     325                 :      * Überprüft den übergebenen Style auf Gültigkeit.                                                                                                                                                                                                                                                                                                                                                                                          
     326                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
     327                 :      * @access public                                                                                                                                                                                                                                                                                                                                                                                                                               
     328                 :      * @param string $name Der zu überprüfende String                                                                                                                                                                                                                                                                                                                                                                                             
     329                 :      * @return mixed String mit Fehlerangabe oder true bei Erfolg                                                                                                                                                                                                                                                                                                                                                                                   
     330                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
     331                 :     function validateStyle($name) {                                                                                                                                                                                                                                                                                                                                                                                                                 
     332               0 :         global $db, $settings;                                                                                                                                                                                                                                                                                                                                                                                                                      
     333               0 :         $dbp = $settings["dbPrefix"];                                                                                                                                                                                                                                                                                                                                                                                                               
     334               0 :         $name = trim(Data::gpcUnescape($name));                                                                                                                                                                                                                                                                                                                                                                                                     
     335               0 :         if (empty($name)) {                                                                                                                                                                                                                                                                                                                                                                                                                         
     336               0 :             return true;                                                                                                                                                                                                                                                                                                                                                                                                                            
     337                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     338               0 :         $styles = Style::getStyleTemplates();                                                                                                                                                                                                                                                                                                                                                                                                       
     339               0 :         foreach($styles as $style) {                                                                                                                                                                                                                                                                                                                                                                                                                
     340               0 :             if ($style[0] == $name) {                                                                                                                                                                                                                                                                                                                                                                                                               
     341               0 :                 return true;                                                                                                                                                                                                                                                                                                                                                                                                                        
     342                 :             }                                                                                                                                                                                                                                                                                                                                                                                                                                       
     343               0 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     344               0 :         return "Ungültige Style-Angabe.";                                                                                                                                                                                                                                                                                                                                                                                                          
     345                 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     346                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
     347                 :      * Speichert den übergebenen String als neuen Style dieses Teams.                                                                                                                                                                                                                                                                                                                                                                              
     348                 :      * Der String sollte vorher mit der Methode validateStyle() validiert worden                                                                                                                                                                                                                                                                                                                                                                    
     349                 :      * sein!                                                                                                                                                                                                                                                                                                                                                                                                                                        
     350                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
     351                 :      * @access public                                                                                                                                                                                                                                                                                                                                                                                                                               
     352                 :      * @param string $name Zu speichernder Style                                                                                                                                                                                                                                                                                                                                                                                                    
     353                 :      * @return boolean Erfolgswert                                                                                                                                                                                                                                                                                                                                                                                                                  
     354                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
     355                 :     function setStyle($name) {                                                                                                                                                                                                                                                                                                                                                                                                                      
     356               0 :         global $db, $settings;                                                                                                                                                                                                                                                                                                                                                                                                                      
     357               0 :         $dbp = $settings["dbPrefix"];                                                                                                                                                                                                                                                                                                                                                                                                               
     358               0 :         $name = trim($name);                                                                                                                                                                                                                                                                                                                                                                                                                        
     359               0 :         if ($this->style == Data::gpcUnescape($name)) {                                                                                                                                                                                                                                                                                                                                                                                             
     360               0 :             return true;                                                                                                                                                                                                                                                                                                                                                                                                                            
     361                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     362               0 :         if ($this->ID == 0) {                                                                                                                                                                                                                                                                                                                                                                                                                       
     363               0 :             if (!$this->createTeam()) {                                                                                                                                                                                                                                                                                                                                                                                                             
     364               0 :                 return false;                                                                                                                                                                                                                                                                                                                                                                                                                       
     365                 :             }                                                                                                                                                                                                                                                                                                                                                                                                                                       
     366               0 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     367               0 :         if (empty($name)) {                                                                                                                                                                                                                                                                                                                                                                                                                         
     368               0 :             $styleSQL = "NULL";                                                                                                                                                                                                                                                                                                                                                                                                                     
     369               0 :         } else {                                                                                                                                                                                                                                                                                                                                                                                                                                    
     370               0 :             $styleSQL = "'".Data::toMysql($name) ."'";                                                                                                                                                                                                                                                                                                                                                                                              
     371                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     372               0 :         $db->query("UPDATE {$dbp}teams SET style=$styleSQL WHERE id='$this->ID'");                                                                                                                                                                                                                                                                                                                                                                  
     373               0 :         if ($db->rows_affected) {                                                                                                                                                                                                                                                                                                                                                                                                                   
     374               0 :             $this->style = Data::gpcUnescape($name);                                                                                                                                                                                                                                                                                                                                                                                                
     375               0 :             return true;                                                                                                                                                                                                                                                                                                                                                                                                                            
     376                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     377               0 :         return false;                                                                                                                                                                                                                                                                                                                                                                                                                               
     378                 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     379                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
     380                 :      * Gibt das Logo des Teams zurück.                                                                                                                                                                                                                                                                                                                                                                                                             
     381                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
     382                 :      * @access public                                                                                                                                                                                                                                                                                                                                                                                                                               
     383                 :      * @return string Logo des Teams                                                                                                                                                                                                                                                                                                                                                                                                                
     384                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
     385                 :     function getLogo() {                                                                                                                                                                                                                                                                                                                                                                                                                            
     386               0 :         return $this->logo;                                                                                                                                                                                                                                                                                                                                                                                                                         
     387                 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     388                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
     389                 :      * Überprüft die übergebene Logo-URL auf Gültigkeit.                                                                                                                                                                                                                                                                                                                                                                                        
     390                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
     391                 :      * @access public                                                                                                                                                                                                                                                                                                                                                                                                                               
     392                 :      * @param string $url Der zu überprüfende String                                                                                                                                                                                                                                                                                                                                                                                              
     393                 :      * @return mixed String mit Fehlerangabe oder true bei Erfolg                                                                                                                                                                                                                                                                                                                                                                                   
     394                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
     395                 :     function validateLogo($url) {                                                                                                                                                                                                                                                                                                                                                                                                                   
     396               0 :         $url = trim(Data::gpcUnescape($url));                                                                                                                                                                                                                                                                                                                                                                                                       
     397               0 :         if (!empty($url) && !Utilities::validateURL($url)) {                                                                                                                                                                                                                                                                                                                                                                                        
     398               0 :             return "Ungültige Logo-URL.";                                                                                                                                                                                                                                                                                                                                                                                                          
     399                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     400               0 :         return true;                                                                                                                                                                                                                                                                                                                                                                                                                                
     401                 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     402                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
     403                 :      * Speichert den übergebenen String als neues Logo dieses Teams.                                                                                                                                                                                                                                                                                                                                                                               
     404                 :      * Der String sollte vorher mit der Methode validateLogo() validiert worden                                                                                                                                                                                                                                                                                                                                                                     
     405                 :      * sein!                                                                                                                                                                                                                                                                                                                                                                                                                                        
     406                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
     407                 :      * @access public                                                                                                                                                                                                                                                                                                                                                                                                                               
     408                 :      * @param string $name Zu speicherndes Logo                                                                                                                                                                                                                                                                                                                                                                                                     
     409                 :      * @return boolean Erfolgswert                                                                                                                                                                                                                                                                                                                                                                                                                  
     410                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
     411                 :     function setLogo($name) {                                                                                                                                                                                                                                                                                                                                                                                                                       
     412               0 :         global $db, $settings;                                                                                                                                                                                                                                                                                                                                                                                                                      
     413               0 :         $dbp = $settings["dbPrefix"];                                                                                                                                                                                                                                                                                                                                                                                                               
     414               0 :         $name = trim($name);                                                                                                                                                                                                                                                                                                                                                                                                                        
     415               0 :         if ($this->logo == Data::gpcUnescape($name)) {                                                                                                                                                                                                                                                                                                                                                                                              
     416               0 :             return true;                                                                                                                                                                                                                                                                                                                                                                                                                            
     417                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     418               0 :         if ($this->ID == 0) {                                                                                                                                                                                                                                                                                                                                                                                                                       
     419               0 :             if (!$this->createTeam()) {                                                                                                                                                                                                                                                                                                                                                                                                             
     420               0 :                 return false;                                                                                                                                                                                                                                                                                                                                                                                                                       
     421                 :             }                                                                                                                                                                                                                                                                                                                                                                                                                                       
     422               0 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     423                 :                                                                                                                                                                                                                                                                                                                                                                                                                                                     
     424               0 :         if (empty($name)) {                                                                                                                                                                                                                                                                                                                                                                                                                         
     425               0 :             $logoSQL = "NULL";                                                                                                                                                                                                                                                                                                                                                                                                                      
     426               0 :         } else {                                                                                                                                                                                                                                                                                                                                                                                                                                    
     427               0 :             $logoSQL = "'".Data::toMysql($name) ."'";                                                                                                                                                                                                                                                                                                                                                                                               
     428                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     429                 :                                                                                                                                                                                                                                                                                                                                                                                                                                                     
     430               0 :         $db->query("UPDATE {$dbp}teams SET logo=$logoSQL WHERE id='$this->ID'");                                                                                                                                                                                                                                                                                                                                                                    
     431               0 :         if ($db->rows_affected) {                                                                                                                                                                                                                                                                                                                                                                                                                   
     432               0 :             $this->logo = Data::gpcUnescape($name);                                                                                                                                                                                                                                                                                                                                                                                                 
     433               0 :             return true;                                                                                                                                                                                                                                                                                                                                                                                                                            
     434                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     435               0 :         return false;                                                                                                                                                                                                                                                                                                                                                                                                                               
     436                 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     437                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
     438                 :      * Gibt die maximale Anzahl von Team-Mitgliedern zurück.                                                                                                                                                                                                                                                                                                                                                                                       
     439                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
     440                 :      * @access public                                                                                                                                                                                                                                                                                                                                                                                                                               
     441                 :      * @return int Maximale Anzahl Team-Mitglieder                                                                                                                                                                                                                                                                                                                                                                                                  
     442                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
     443                 :     function getMaxMembers() {                                                                                                                                                                                                                                                                                                                                                                                                                      
     444               0 :         return $this->maxMembers;                                                                                                                                                                                                                                                                                                                                                                                                                   
     445                 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     446                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
     447                 :      * Überprüft den übergebenen Wert der maximalen Teilnehmerzahl auf Gültigkeit.                                                                                                                                                                                                                                                                                                                                                              
     448                 :      * Der Wert muss ein Integer >= 0 sein.                                                                                                                                                                                                                                                                                                                                                                                                         
     449                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
     450                 :      * @access public                                                                                                                                                                                                                                                                                                                                                                                                                               
     451                 :      * @param mixed $maxMembers Der zu überprüfende String oder Integer                                                                                                                                                                                                                                                                                                                                                                           
     452                 :      * @return mixed String mit Fehlerangabe oder true bei Erfolg                                                                                                                                                                                                                                                                                                                                                                                   
     453                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
     454                 :     function validateMaxMembers($maxMembers) {                                                                                                                                                                                                                                                                                                                                                                                                      
     455               0 :         if (strval(intval($maxMembers)) != $maxMembers || $maxMembers < 0) {                                                                                                                                                                                                                                                                                                                                                                        
     456               0 :             return "Ungültiger Wert der maximalen Teilnehmerzahl.";                                                                                                                                                                                                                                                                                                                                                                                
     457                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     458               0 :         return true;                                                                                                                                                                                                                                                                                                                                                                                                                                
     459                 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     460                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
     461                 :      * Speichert die übergebene Zahl als die maximale Anzahl von Team-Mitgliedern.                                                                                                                                                                                                                                                                                                                                                                 
     462                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
     463                 :      * @access public                                                                                                                                                                                                                                                                                                                                                                                                                               
     464                 :      * @param int $maxMembers Zu speichernde Anzahl Team-Mitglieder                                                                                                                                                                                                                                                                                                                                                                                 
     465                 :      * @return boolean Erfolgswert                                                                                                                                                                                                                                                                                                                                                                                                                  
     466                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
     467                 :     function setMaxMembers($maxMembers) {                                                                                                                                                                                                                                                                                                                                                                                                           
     468               0 :         global $db, $settings;                                                                                                                                                                                                                                                                                                                                                                                                                      
     469               0 :         $dbp = $settings["dbPrefix"];                                                                                                                                                                                                                                                                                                                                                                                                               
     470               0 :         if (strval(intval($maxMembers)) != $maxMembers || $maxMembers < 0) {                                                                                                                                                                                                                                                                                                                                                                        
     471               0 :             return false;                                                                                                                                                                                                                                                                                                                                                                                                                           
     472                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     473               0 :         if ($this->maxMembers == $maxMembers) {                                                                                                                                                                                                                                                                                                                                                                                                     
     474               0 :             return true;                                                                                                                                                                                                                                                                                                                                                                                                                            
     475                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     476                 :                                                                                                                                                                                                                                                                                                                                                                                                                                                     
     477               0 :         if ($this->ID == 0) {                                                                                                                                                                                                                                                                                                                                                                                                                       
     478               0 :             if (!$this->createTeam()) {                                                                                                                                                                                                                                                                                                                                                                                                             
     479               0 :                 return false;                                                                                                                                                                                                                                                                                                                                                                                                                       
     480                 :             }                                                                                                                                                                                                                                                                                                                                                                                                                                       
     481               0 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     482               0 :         $db->query("UPDATE {$dbp}teams SET max_members='$maxMembers' WHERE id='$this->ID'");                                                                                                                                                                                                                                                                                                                                                        
     483               0 :         if ($db->rows_affected) {                                                                                                                                                                                                                                                                                                                                                                                                                   
     484               0 :             $this->maxMembers = intval($maxMembers);                                                                                                                                                                                                                                                                                                                                                                                                
     485               0 :             return true;                                                                                                                                                                                                                                                                                                                                                                                                                            
     486                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     487               0 :         return false;                                                                                                                                                                                                                                                                                                                                                                                                                               
     488                 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     489                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
     490                 :      * Gibt die Kurs-ID des Teams zurück.                                                                                                                                                                                                                                                                                                                                                                                                          
     491                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
     492                 :      * @access public                                                                                                                                                                                                                                                                                                                                                                                                                               
     493                 :      * @return int Kurs-ID des Teams                                                                                                                                                                                                                                                                                                                                                                                                                
     494                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
     495                 :     function getCourseID() {                                                                                                                                                                                                                                                                                                                                                                                                                        
     496               0 :         return $this->courseID;                                                                                                                                                                                                                                                                                                                                                                                                                     
     497                 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     498                 :     /**                                                                                                                                                                                                                                                                                                                                                                                                                                             
     499                 :      * Speichert den übergebenen Integer als neue Kurs-ID dieses Team.                                                                                                                                                                                                                                                                                                                                                                             
     500                 :      *                                                                                                                                                                                                                                                                                                                                                                                                                                              
     501                 :      * @access public                                                                                                                                                                                                                                                                                                                                                                                                                               
     502                 :      * @param integer $courseID Zu speichernde Kurs-ID                                                                                                                                                                                                                                                                                                                                                                                              
     503                 :      * @return boolean Erfolgswert                                                                                                                                                                                                                                                                                                                                                                                                                  
     504                 :      */                                                                                                                                                                                                                                                                                                                                                                                                                                             
     505                 :     function setCourseID($courseID) {                                                                                                                                                                                                                                                                                                                                                                                                               
     506               0 :         global $db, $settings;                                                                                                                                                                                                                                                                                                                                                                                                                      
     507               0 :         $dbp = $settings["dbPrefix"];                                                                                                                                                                                                                                                                                                                                                                                                               
     508               0 :         if ($this->courseID == $courseID) {                                                                                                                                                                                                                                                                                                                                                                                                         
     509               0 :             return true;                                                                                                                                                                                                                                                                                                                                                                                                                            
     510                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     511               0 :         if (strval(intval($courseID)) != $courseID || $courseID < 1) {                                                                                                                                                                                                                                                                                                                                                                              
     512               0 :             return false;                                                                                                                                                                                                                                                                                                                                                                                                                           
     513                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     514                 :                                                                                                                                                                                                                                                                                                                                                                                                                                                     
     515               0 :         if ($this->ID == 0) {                                                                                                                                                                                                                                                                                                                                                                                                                       
     516               0 :             if (!$this->createTeam()) {                                                                                                                                                                                                                                                                                                                                                                                                             
     517               0 :                 return false;                                                                                                                                                                                                                                                                                                                                                                                                                       
     518                 :             }                                                                                                                                                                                                                                                                                                                                                                                                                                       
     519               0 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     520               0 :         $db->query("UPDATE {$dbp}teams SET course_id='$courseID' WHERE id='$this->ID'");                                                                                                                                                                                                                                                                                                                                                            
     521                 :                                                                                                                                                                                                                                                                                                                                                                                                                                                     
     522               0 :         if ($db->rows_affected) {                                                                                                                                                                                                                                                                                                                                                                                                                   
     523               0 :             $this->courseID = intval($courseID);                                                                                                                                                                                                                                                                                                                                                                                                    
     524               0 :             return true;                                                                                                                                                                                                                                                                                                                                                                                                                            
     525                 :         }                                                                                                                                                                                                                                                                                                                                                                                                                                           
     526               0 :         return false;                                                                                                                                                                                                                                                                                                                                                                                                                               
     527                 :     }                                                                                                                                                                                                                                                                                                                                                                                                                                               
     528                 : }                                                                                                                                                                                                                                                                                                                                                                                                                                                   
     529                 :                                                                                                                                                                                                                                                                                                                                                                                                                                                     

Generated by PHPUnit 3.2.21 and Xdebug 2.0.3 at Thu Nov 26 17:01:15 CET 2009.